<template>
    <div>
        <h1>http请求测试</h1>
        <br>
        <br>
        <br>
        无参请求
        <button @click="NoParameter()">无参请求</button>
        <p>{{NoParameterData}}</p>
        <hr>
        <br>
        带参请求
        <button @click="Parameter()">带参请求</button>
        <p>{{ParameterData}}</p>
        <hr>
        <br>
        Post请求
        <button @click="post()">Post请求</button>
        Get请求
        <button @click="get()">Get请求</button>
        <p>{{PGData}}</p>
        <hr>
    </div>
</template>

<script>
    import {NoParameter,Parameter,get,post} from "../../server/api";
    export default {
        name: "test2",
        data(){
            return{
                NoParameterData:'',//无参响应回的数据
                ParameterData:'',//带参响应回的数据
                PGData:'',//post/get公共接收数据
            }
        },
        methods:{
            NoParameter(){
                let _this=this;
                NoParameter().then(data => {
                    console.log(data);
                    _this.NoParameterData=data;
                })
            },
            Parameter(){
                let _this=this;
                Parameter({
                    id:'0001',
                    name:'MM',
                    age:'16'

                }).then(data => {
                    console.log(data);
                    _this.ParameterData=data;
                })
            },
            post(){
                let _this=this;
                post().then(data => {
                    console.log(data);
                    _this.PGData=data;
                })
            },
            get(){
                let _this=this;
                get().then(data => {
                    console.log(data);
                    _this.PGData=data;
                })
            },
        }
    }
</script>

<style scoped>

</style>
